#include <cppunit/config/SourcePrefix.h>
#include "TestQuery.h"

#include <iostream>
#include <string>

void TestQuery::setUp() {

}

void TestQuery::tearDown() {

}


// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( TestQuery ); // Note 4 

// method to test the constructor
void TestQuery::testEvaluation()
{  // Note 5
	QueryCreator *queryCreator = QueryCreator::getQueryCreator();

	//Create some new Synonyms
	Synonym *assignA = new Synonym(Q_ASSIGN, "a");
	Synonym *assignB = new Synonym(Q_ASSIGN, "b");
	Synonym *assignC = new Synonym(Q_ASSIGN, "c");

	//Create some new Results
	Result *resultA = new Result(Q_ASSIGN, "a");

	//Queries (currently uses Synonym too, will change in future)
	QueryType queryType = MODIFIES;
	Synonym *queryArg1 = new Synonym(Q_ASSIGN, "a");
	Synonym *queryArg2 = new Synonym(Q_STATEMENT, "1");
	Synonym *queryArg3 = new Synonym(Q_STATEMENT, "1");

	//Current Full Query looks like this
	//assign a,b,c;
	//Select a such that Modifies(a,1);

	//Create a new complete query (Run this everytime you want a new query)
	queryCreator->createNewQuery();

	//Start populating the query
	queryCreator->addSynonym(assignA);
	queryCreator->addSynonym(assignB);
	queryCreator->addSynonym(assignC);
	queryCreator->addResult(resultA);
	queryCreator->addQuery(queryType, queryArg1, queryArg2, queryArg3);

	//Finally, get the complete query
	CompleteQuery *currentQuery = queryCreator->getCompleteQuery();
	Synonym *synonymA = currentQuery->getDeclarationParameters().at(0);
	CPPUNIT_ASSERT(synonymA->getVariable() == "a");
	Result *resA = currentQuery->getResult();
	CPPUNIT_ASSERT(resA->getVariable() == "a");
}